/*
 * Copyright (c) 2016 zhangcm. All Rights Reserved.
 */
package com.deram.ctin.common.utils;

import com.google.common.base.Preconditions;
import org.apache.commons.codec.digest.DigestUtils;

/**
 * @author zhangcm
 * @version 1.0, 2017/8/27
 */
public class PasswordUtils {

    public static String encrypt(String source, String salt){
        Preconditions.checkNotNull(source);
        Preconditions.checkNotNull(salt);
        return DigestUtils.md5Hex(source + salt);
    }

    public static Boolean isEqual(String encryptStr, String source, String salt){
        Preconditions.checkNotNull(encryptStr);
        String sourceEncryptStr = encrypt(source, salt);
        return encryptStr.equals(sourceEncryptStr);
    }
}
